package com.mk.web.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.mk.web.model.Bottle;
import com.mk.web.service.BottleService;
import com.mk.web.service.impl.BottleServiceImpl;

/**
 * Created by WangChen on 2018/11/27 15:46.
 */
@WebServlet("/bottle")
public class BottleServlet extends HttpServlet {

    private BottleService bottleService = new BottleServiceImpl();
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        req.setCharacterEncoding("utf-8");
        resp.setContentType("text/html;charset=utf-8");
        String name = req.getParameter("name");
        double size = Double.parseDouble(req.getParameter("size"));
        List<Bottle> bottleList = bottleService.findByNameAndSize(name, size);
        resp.getWriter().write(bottleList.toString());

    }
}
